local M = {}

function M.plugin_setup()
  local builtin = lvim.builtin
  --nvimtree
  builtin.nvimtree.setup.renderer.icons.show.git = false
  builtin.nvimtree.setup.view.side = "left"

  -- toggleterm
  builtin["terminal"].direction = "horizontal"
  builtin["terminal"].size = 6
  builtin["terminal"].float_opts.border = "none"

  local header = {
    [[                                                                                ]],
    [[░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░      ░▒▓█▓▒░      ░▒▓████████▓▒░▒▓████████▓▒░ ]],
    [[░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░             ░▒▓█▓▒░      ░▒▓█▓▒░      ░▒▓█▓▒░        ]],
    [[░▒▓█▓▒░▒▓█▓▒░      ░▒▓█▓▒░             ░▒▓█▓▒░      ░▒▓█▓▒░      ░▒▓█▓▒░        ]],
    [[░▒▓█▓▒░▒▓█▓▒░      ░▒▓██████▓▒░        ░▒▓█▓▒░      ░▒▓██████▓▒░ ░▒▓██████▓▒░   ]],
    [[░▒▓█▓▒░▒▓█▓▒░      ░▒▓█▓▒░             ░▒▓█▓▒░      ░▒▓█▓▒░      ░▒▓█▓▒░        ]],
    [[░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░             ░▒▓█▓▒░      ░▒▓█▓▒░      ░▒▓█▓▒░        ]],
    [[░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░      ░▒▓████████▓▒░▒▓████████▓▒░▒▓████████▓▒░ ]],
    [[                                     Happy fun                                  ]],
  }
  builtin.alpha.dashboard.section.header.val = header
  builtin.alpha.dashboard.section.footer.val = "Hi Ice Lee! Have a happy day!"

  -- 修改Lazy插件管理的giturl，国内环境使用github代理访问
  lvim.lazy.opts.git.url_format ="https://ghfast.top/https://github.com/%s.git"


  -- for key, _ in pairs(builtin) do
  --   print(key)
  -- end
end

function M.config()
  M.plugin_setup()
  local opt = vim.opt

  opt.formatoptions:remove("c")       -- 取消自动注释，例如回车之后  不添加注释
  opt.formatoptions:remove("r")       --
  opt.formatoptions:remove("o")       --

  opt.relativenumber = true           -- 相对行号
  opt.wrap           = true           --
  opt.cursorline     = true           --
  opt.swapfile       = false          --
  lvim.colorscheme   = "slate"        -- 主题
  vim.o.viewoptions  = "cursor,folds" -- 保存光标位置和折叠状态
  vim.o.foldmethod   = "indent"       --
  vim.cmd                             -- 打开/关闭文件自动保存/加载view
  [[
      augroup remember_folds
        autocmd!
          autocmd BufWinLeave * silent! mkview
          autocmd BufWinEnter * silent! loadview
        augroup END
  ]]

  vim.cmd --保存文件自动保存view
  [[
    augroup save_view_on_save
      autocmd!
      autocmd BufWritePre * silent! mkview
      autocmd BufWinEnter * silent! loadview
    augroup END
  ]]
end

return M
